package com.wang.home.find;

import com.alibaba.fastjson.JSONObject;
import com.wang.home.HomeReq;
import com.wang.tool.dagre.DagreContext;
import com.wang.tool.dagre.node.DagreNode;
import com.wang.tool.common.Container;

import java.util.Collection;
import java.util.List;

/**
 * @Description
 * @Author shaopeng
 * @Date 2021/9/28
 * @Version 1.0
 */
public class CircleFinder implements DagreNode<HomeReq> {

    @Override
    public Collection<String> getDependIds() {
        return FindWorkerEnum.CIRCLE.getDependCodes();
    }

    @Override
    public String getId() {
        return FindWorkerEnum.CIRCLE.name();
    }

    @Override
    public boolean isSync() {
        return false;
    }


    @Override
    public Object preCheck(DagreContext<HomeReq> context) {
        return Container.build(20);
    }

    @Override
    public Object execute(DagreContext<HomeReq> context1) throws Exception {
        HomeReq param = context1.getParam();
        if (param.getUid()==null || param.getLng()==null) {
            throw new IllegalArgumentException("未发现circle");
        }
//        Thread.sleep(80);
//        context1.cancelNode(FindWorkerEnum.SEA2.name());
        param.setCircleId("23");
        List<JSONObject> user = context1.getNodeResult("USER", List.class);
        user.get(0).put("1", 2);
        return user;
    }
}
